package com.sfac.javaEE;



import com.sfac.javaEE.service.CService;

import com.sfac.javaEE.service.Impl.CServiceImpl;

import com.sfac.javaEE.util.ConfigUtil2;

import com.sfac.javaEE.util.JDBCConfig;

import org.springframework.context.ApplicationContext;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import org.springframework.context.annotation.ComponentScan;

import org.springframework.context.annotation.Configuration;


@Configuration

@ComponentScan

public class SpringApp {

    public static void main(String[] args) {

        // 读取 xml 配置文件的方式启动 IOC 容器

//        ApplicationContext applicationContext =

//                new ClassPathXmlApplicationContext("application.xml");

//        AService aService = applicationContext.getBean(AServiceImpl.class);

//        aService.call();



        ApplicationContext app = new AnnotationConfigApplicationContext(SpringApp.class);

//        CService cService = app.getBean(CServiceImpl.class);

//        cService.ca();

//        var configUtil = app.getBean(ConfigUtil2.class);

//        var properties = configUtil.getProperties();

//        System.out.println(properties.getProperty("jdbc.url"));

        JDBCConfig jdbcConfig = app.getBean(JDBCConfig.class);

        System.out.println(jdbcConfig.getDriverClassName());

    }

}

